package com.xneure.enums;

import com.xneure.utils.cipher.AESCoder;
import com.xneure.utils.cipher.SimpleEncode;

public enum Armour {
	AES {
		@Override
		public byte[] encode(byte[] bt) {
			return encode(bt, pwd);
		}

		@Override
		public byte[] encode(byte[] bt, String pwd) {
			try {
				return AESCoder.encrept(bt, pwd);
			} catch (Exception e) {
				return bt;
			}
		}

		@Override
		public byte[] decode(byte[] bt) {
			return decode(bt, pwd);
		}

		@Override
		public byte[] decode(byte[] bt, String pwd) {
			try {
				return AESCoder.decrept(bt, pwd);
			} catch (Exception e) {
				return null;
			}
		}
	},
	HEX {
		@Override
		public byte[] encode(byte[] bt) {
			return encode(bt, pwd);
		}

		@Override
		public byte[] encode(byte[] bt, String pwd) {
			return SimpleEncode.encodeHex(bt).getBytes();
		}

		@Override
		public byte[] decode(byte[] bt) {
			return decode(bt, pwd);
		}

		@Override
		public byte[] decode(byte[] bt, String pwd) {
			return SimpleEncode.decodeHex(new String(bt));
		}
	},
	BASE64 {
		@Override
		public byte[] encode(byte[] bt) {
			return encode(bt, pwd);
		}

		@Override
		public byte[] encode(byte[] bt, String pwd) {
			return SimpleEncode.encodeBase64(bt).getBytes();
		}

		@Override
		public byte[] decode(byte[] bt) {
			return decode(bt, pwd);
		}

		@Override
		public byte[] decode(byte[] bt, String pwd) {
			return SimpleEncode.decodeBase64(new String(bt));
		}
	},
	Simple {
		@Override
		public byte[] encode(byte[] bt) {
			return encode(bt, pwd);
		}

		@Override
		public byte[] encode(byte[] bt, String pwd) {
			return SimpleEncode.encodeBase62(bt).getBytes();
		}

		@Override
		public byte[] decode(byte[] bt) {
			return decode(bt, pwd);
		}

		@Override
		public byte[] decode(byte[] bt, String pwd) {
			return SimpleEncode.encodeBase62(bt).getBytes();
		}
	},;

	static final String pwd = "xneure";

	public abstract byte[] encode(byte[] bt);

	public abstract byte[] encode(byte[] bt, String pwd);

	public abstract byte[] decode(byte[] bt);

	public abstract byte[] decode(byte[] bt, String pwd);
	
	

}